import sys
from PyQt5.QtWidgets import QSlider, QApplication, QVBoxLayout, QHBoxLayout, QWidget, QLabel
from PyQt5.QtCore import Qt

class RangeAndTickControl(QWidget):
    def __init__(self):
        super().__init__()
        self.setup_ui()
        self.demo_range_operations()
    
    def setup_ui(self):
        layout = QVBoxLayout()
        
        self.slider = QSlider(Qt.Horizontal)
        layout.addWidget(self.slider)
        self.setLayout(layout)
    
    def demo_range_operations(self):
        # 设置数值范围
        self.slider.setMinimum(0)           # 最小值
        self.slider.setMaximum(200)         # 最大值
        self.slider.setRange(0, 100)        # 同时设置最小最大值
        
        # 设置当前值
        self.slider.setValue(75)
        
        # 获取范围信息
        min_val = self.slider.minimum()
        max_val = self.slider.maximum()
        current_val = self.slider.value()
        
        print(f"范围: {min_val} - {max_val}, 当前值: {current_val}")
        
        # 刻度控制
        self.slider.setTickPosition(QSlider.TicksBelow)  # 刻度位置
        self.slider.setTickInterval(10)                  # 刻度间隔
        self.slider.setSingleStep(5)                     # 单步变化量
        self.slider.setPageStep(20)                      # 页面步长


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = RangeAndTickControl()
    window.show()
    sys.exit(app.exec_())